package com.example.demo.controller;


import com.example.demo.bean.Person;
import com.example.demo.bean.User;
import com.example.demo.mapper.UserMapper;
import com.example.demo.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

@RestController
public class DemoController {


    @Autowired(required = false)
    private UserMapper userMapper;

    @RequestMapping("/home")
    public ModelMap index(@RequestParam(name="account") String account){
        User user = userMapper.selectUserByAccount(account);
        ModelMap modelMap = new ModelMap();
        modelMap.put("status", 1);
        modelMap.put("data", user);
        modelMap.put("msg", "成功");
        return modelMap;
    }


    @Autowired
    private PersonService personService;

    @RequestMapping("/hello")
    public Person hello() {
        return personService.getPersonInfo();
    }
}
